﻿// Shader-Based-Image-Processing (SBIP)
// http://code.google.com/p/sbip/
//
// Copyright © Frank Nagl, 2009-2011
// admin@franknagl.de
//
namespace SBIP.OptionsForms
{
    using System;
    using System.Windows.Forms;
    using Filter;

    /// <summary>Filter specified properties form.</summary>
    public partial class ThresholdRGBForm : Form
    {
        readonly ThresholdRGB filter;

        /// <summary>
        /// Initializes a new instance of the <see cref="ThresholdRGBForm"/> class.
        /// </summary>
        /// <param name="processor">The processor.</param>
        public ThresholdRGBForm(Processor processor)
        {
            InitializeComponent();
            filter = new ThresholdRGB();
            processor.Filter = filter;
        }

        private void RedTrackBarValueChanged(object sender, EventArgs e)
        {
            filter.R = (byte)RedTrackBar.Value;
            RedValue.Text = filter.R.ToString();
        }

        private void GreenTrackBarValueChanged(object sender, EventArgs e)
        {
            filter.G = (byte)GreenTrackBar.Value;
            GreenValue.Text = filter.G.ToString();
        }

        private void BlueTrackBarValueChanged(object sender, EventArgs e)
        {
            filter.B = (byte)BlueTrackBar.Value;
            BlueValue.Text = filter.B.ToString();
        }

        private void OnRadioButtonCheckedChanged(object sender, EventArgs e)
        {
            if (((RadioButton)sender).Checked)
                filter.Binarization = true;
        }

        private void OffRadioButtonCheckedChanged(object sender, EventArgs e)
        {
            if (((RadioButton)sender).Checked)
                filter.Binarization = false;
        }
    }
}
